﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WindowsFormsApplication1
{
    public class StudentsDBHeper
    {
        private readonly static string ConString = "server = .;database=Schools;uid =sa;pwd=lsy6796159..";

        public static DataTable GetSearch(string sql)
        {
            SqlConnection sqlconn = new SqlConnection(ConString);
            sqlconn.Open();
            SqlDataAdapter sqldar = new SqlDataAdapter(sql, sqlconn);
            DataTable dt = new DataTable();
            sqldar.Fill(dt);
            return dt;
        }

        public static int Addordelete(string sql)
        {
            SqlConnection sqlconn = new SqlConnection(ConString);
            sqlconn.Open();
            SqlCommand sqlcmd = new SqlCommand(sql, sqlconn);
            int i = sqlcmd.ExecuteNonQuery();
            return i;
        }
    }
}
